# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=nbviewer
pkgbase=mingw-w64-python-jupyter-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-jupyter-${_realname}
pkgver=1.0.1
pkgrel=8
pkgdesc='Render Jupyter Notebooks as static web pages (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://jupyter.org'
msys2_repository_url="https://github.com/jupyter/nbviewer"
msys2_references=(
  'purl: pkg:pypi/nbviewer'
)
license=('spdx:BSD-4-Clause')
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-elasticsearch
    ${MINGW_PACKAGE_PREFIX}-python-ipython
    ${MINGW_PACKAGE_PREFIX}-python-jupyter-nbconvert
    ${MINGW_PACKAGE_PREFIX}-python-jupyter-nbformat
    ${MINGW_PACKAGE_PREFIX}-python-jupyter_client
    ${MINGW_PACKAGE_PREFIX}-python-markdown
    ${MINGW_PACKAGE_PREFIX}-python-pycurl
    ${MINGW_PACKAGE_PREFIX}-python-statsd
)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-python-build
    ${MINGW_PACKAGE_PREFIX}-python-installer
    ${MINGW_PACKAGE_PREFIX}-python-setuptools
    ${MINGW_PACKAGE_PREFIX}-python-invoke
    ${MINGW_PACKAGE_PREFIX}-python-versioneer
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('85233e53bc78ff216a99a2676a7e5f9557f0d4973797c36fdb81c9cc48821a73')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}/
  # Disable check for non-windows modules
  sed -i "s|newrelic!=2.80.0.60||g" requirements.txt
  sed -i "s|pylibmc||g" requirements.txt

  rm -f "${srcdir}"/${_realname}-${pkgver}/versioneer.py | true
}

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}"/python-build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl
}
